package com.paso.mycommons.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Classname: RespBean
 * @Description: 公共返回对象
 * @Date: 2021/2/3 22:21
 * @Created: by Wang Xu
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {

    private int code;
    private String message;
    private Object data;

    /**
     * @description: 成功返回结果
     * @param: []
     * @return: com.example.seckill.vo.RespBean
     * @author: wangxu
     * @date: 2021/2/3 22:38
     */
    public static RespBean success(){
        return  new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), null);
    }

    public static RespBean success(Object obj){
        return  new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), obj);
    }


    /**
     * @description: 失败返回结果
     * @param: [respBeanEnum]
     * @return: com.example.seckill.vo.RespBean
     * @author: wangxu
     * @date: 2021/2/3 22:44
     */
    public static RespBean error(RespBeanEnum respBeanEnum){
        return  new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    public static RespBean error(RespBeanEnum respBeanEnum,Object obj){
        return  new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), obj);
    }
}
